package com.legstar.talend.xsd2xml;

import java.util.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;

/**
 * Talend XML schema.
 * 
 * */
@XStreamAlias("schema")
public class TosSchema implements Cloneable {

    @XStreamImplicit()
    private List<TosSchemaColumn> columns = new ArrayList<TosSchemaColumn>();

    /** {@inheritDoc} */
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        sb.append("columns" + ":'" + columns + "'");
        sb.append("]");
        return sb.toString();
    }

    /**
     * @return the schema columns
     */
    public List<TosSchemaColumn> getColumns() {
        return columns;
    }

    /**
     * @param column a new schema column
     */
    public void addSchemaColumn(final TosSchemaColumn column) {
        columns.add(column);
    }

    /**
     * @aram the schema columns
     */
    public void setColumns(List<TosSchemaColumn> columns) {
        this.columns = columns;
    }

    @Override
    protected TosSchema clone() {
        TosSchema clone = new TosSchema();
        for (TosSchemaColumn column : getColumns()) {
            clone.addSchemaColumn(column.clone());
        }
        return clone;
    }

}
